/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundary.display;

import entity.Employee;
import entity.Entity;
import java.awt.Frame;

/**
 *
 * @author Juan
 */
public class PEmployeeDisplay extends EntityDisplayPanel {

    /**
     * Creates new form PEmployeeRegistration
     */
    public PEmployeeDisplay() {
        initComponents();
    }

    @Override
    public void setCurrentEntity(Entity entity) throws IllegalArgumentException {
        Employee currentEmployee;
        if (entity instanceof Employee) {
            currentEntity = entity;
            currentEmployee = (Employee) entity;
            TFName.setText(currentEmployee.getName());
            TFIdNum.setText(currentEmployee.getIdNum());
            TFIdType.setText(currentEmployee.getIdType());
            TFUsername.setText(currentEmployee.getLogin());
        } else {
            throw new IllegalArgumentException("The object to be displayed is not an Employee.");
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        TFName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        TFIdNum = new javax.swing.JTextField();
        TFIdType = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        TFUsername = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        BClose = new javax.swing.JButton();
        BShowPassword = new javax.swing.JButton();

        jLabel1.setText("Nombre del Empleado:");

        TFName.setEditable(false);

        jLabel2.setText("Número de Documento:");

        TFIdNum.setEditable(false);

        TFIdType.setEnabled(false);

        jLabel3.setText("Nombre de Usuario:");

        TFUsername.setEditable(false);

        jLabel4.setText("Contraseña:");

        BClose.setText("Cerrar");
        BClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCloseActionPerformed(evt);
            }
        });

        BShowPassword.setText("Mostrar Contraseña");
        BShowPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BShowPasswordActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(BShowPassword)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TFUsername)
                            .addComponent(TFName)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addComponent(TFIdNum, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(TFIdType, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(BClose))
                                .addGap(0, 150, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFIdNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TFIdType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addGap(4, 4, 4)
                .addComponent(TFUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BShowPassword)
                .addGap(18, 18, 18)
                .addComponent(BClose)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void BCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCloseActionPerformed
        buttonTabComponent.closeTab();
    }//GEN-LAST:event_BCloseActionPerformed

    private void BShowPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BShowPasswordActionPerformed
        DPasswordDisplay dPasswordDisplay = new DPasswordDisplay((Frame) getTopLevelAncestor(), true);
        Employee currentEmployee = (Employee) currentEntity;
        dPasswordDisplay.setPassword(currentEmployee.getPassword());
        dPasswordDisplay.setLocationRelativeTo(this);
        dPasswordDisplay.setVisible(true);
    }//GEN-LAST:event_BShowPasswordActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BClose;
    private javax.swing.JButton BShowPassword;
    private javax.swing.JTextField TFIdNum;
    private javax.swing.JTextField TFIdType;
    private javax.swing.JTextField TFName;
    private javax.swing.JTextField TFUsername;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables
}
